<template>
  <div v-if="asyncLoadCompVisible">
    <component :is="apps" :childVisible="childCompForm.visible" :bizData="bizData" :comments="comments"
               :auditStatus="auditStatus" :passParamObj="passParam"
               @closeChild="handleChildCompFormClose"
               @successChild="handleChildCompFormSuccess"></component>
  </div>
</template>
<script>
    import Vue from "vue";

    export default {
        name: "AsyncLoadComp",
        data() {
            return {
                child: this.comChilds,
                passParam: this.checkParam,
                apps: {},
                childCompForm: {
                    visible: false
                },
                bizData: "",
                comments: "",
                auditStatus:""
            };
        },
        props: {
            asyncLoadCompVisible: {
                type: Boolean,
                default: false
            },
            comChilds: {
                type: String
            },
            checkParam: {
                type: Object
            }
        },
        methods: {
            handleChildCompFormClose() {
                this.childCompForm.visible = false;
                this.apps = {};
                this.$emit("close")
            },
            handleChildCompFormSuccess() {
                this.childCompForm.visible = false;
                this.apps = {};
                this.$emit("success")
            }
        },
        beforeMount() {

        },
        watch: {
            asyncLoadCompVisible: {
                handler(newVal, oldVal) {
                    if (newVal) {
                        console.log("传参对象：")
                        console.log(this.comChilds)
                        console.log(this.checkParam)
                        if (this.comChilds&&this.comChilds.length>0) {
                            // this.apps=() => import('../' + this.comChilds + '.vue')
                            this.bizData = this.checkParam.bizData;
                            this.comments = this.checkParam.comment;
                            this.childCompForm.visible = this.checkParam.childVisible;
                            this.auditStatus = this.checkParam.auditStatus;
                            this.passParam = this.checkParam;
                            this.apps = () => import('../' + this.comChilds + '.vue')
                        }
                    }
                }
            }
        }

    };
</script>
<style scoped>
</style>
